﻿Shader "Custom/RadialAmbiguity"
{
    Properties
    {
        _MainTex ("Albedo (RGB)", 2D) = "white" {}
    }
    SubShader
    {
        CGINCLUDE

        #include "UnityCG.cginc"

        sampler2D _MainTex;
        float _centerPosX, _centerPosY;
        float _intensety;

        struct a2v
        {
            float4 vertex : POSITION;
            float2 uv : TEXCOORD0;
        };
        
        struct v2f 
        {
            float4 pos : SV_POSITION;
            float2 uv : TEXCOORD0;
        };

        v2f vert(a2v v)
        {
            v2f i;
            i.pos = UnityObjectToClipPos(v.vertex);
            i.uv = v.uv;
            return i;
        }

        ENDCG

        
        pass
        {
            CGPROGRAM
            
            #pragma vertex vert
            #pragma fragment frag

            fixed4 frag(v2f i) : SV_TARGET
            {
                float2 center = float2(_centerPosX, _centerPosY);
                i.uv -= center;

                float scale = 1;
                float4 color;
                for(int j = 1; j < 16; j++)
                {
                    color += tex2D(_MainTex, i.uv * scale + center);
                    scale += (j + 2) * _intensety;
                }
                color /= 16;

                return color;
            }
            
            ENDCG
        }
        
    }
    FallBack "Diffuse"
}
